﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IsmsExplorer.Model.Documents;
using IsmsExplorer.Infrastructure.Helper;
using IsmsExplorer.Infrastructure.EntityFactoryFramework;

namespace IsmsExplorer.Infrastructure.Repositories.Documents {
    internal class IsmsDocumentLinkFactory : IEntityFactory<IsmsDocumentLink> {
        internal static class FieldNames {
            public const string ID = "ID";
            public const string RepositoryTypeID = "RepositoryTypeID";
            public const string Name = "Name";
            public const string URL = "URL";
            public const string RepositoryVersionNumber = "RepositoryVersionNumber";
            public const string ProjectID = "ProjectID";
            public const string DocumentTypeID = "DocumentTypeID";
            public const string Description = "Description";
        } // end internal static class FieldNames

        public IsmsDocumentLink BuildEntity(System.Data.IDataReader reader) {
            return new IsmsDocumentLink() {
                DocumentID = DataHelper.GetGuid(reader[FieldNames.ID]),
                RepositoryTypeID = DataHelper.GetInteger(reader[FieldNames.RepositoryTypeID]),
                DocumentName = reader[FieldNames.Name].ToString(),
                DocumentURL = reader[FieldNames.URL].ToString(),
                ProjectID = DataHelper.GetInteger(reader[FieldNames.ProjectID]),
                RepositoryVersion = DataHelper.GetString(reader[FieldNames.RepositoryVersionNumber]),
                DocumentTypeID = DataHelper.GetInteger(reader[FieldNames.DocumentTypeID]),
                Description = DataHelper.GetString(reader[FieldNames.Description])
            };
        }
    }
}
